package com.kavin.treeview;

import android.os.Bundle;
import android.text.TextUtils;

import androidx.appcompat.app.AppCompatActivity;


import com.kavin.treeviewlib.AppConstants;
import com.kavin.treeviewlib.model.NodeModel;
import com.kavin.treeviewlib.model.TreeModel;
import com.kavin.treeviewlib.util.DensityUtils;
import com.kavin.treeviewlib.util.LOG;
import com.kavin.treeviewlib.util.StringTool;
import com.kavin.treeviewlib.view.RightTreeLayoutManager;
import com.kavin.treeviewlib.view.TreeView;

import java.io.File;
import java.util.ArrayList;
import java.util.LinkedList;

public class MainActivity extends AppCompatActivity {

    private TreeView editMapTreeView;
    private TreeModel<String> mTreeModel;
    private String[] mOwantFilesArray;
    private String saveDefaultFilePath;
    private String mDefaultFilePath;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        editMapTreeView = (TreeView) findViewById(R.id.edit_map_tree_view);


        int dx = DensityUtils.dp2px(getApplicationContext(), 20);
        int dy = DensityUtils.dp2px(getApplicationContext(), 20);
        int screenHeight = DensityUtils.dp2px(getApplicationContext(), 720);
        editMapTreeView.setTreeLayoutManager(new RightTreeLayoutManager(dx, dy, screenHeight));

        createDefaultTreeModel();
    }


    public void createDefaultTreeModel() {


        NodeModel<String> plan = new NodeModel<>("root");
        plan.setChildNodes(getChildeNodes());


        mTreeModel = new TreeModel<>(plan);

        editMapTreeView.setTreeModel(mTreeModel);
    }

    private LinkedList<NodeModel<String>> getChildeNodes() {

        LinkedList<NodeModel<String>> childNodes = new LinkedList<NodeModel<String>>();
        NodeModel<String> node = new NodeModel<>("aa");
        node.setChildNodes(getChildeNodes2());
        childNodes.add(node);
        childNodes.add(new NodeModel<>("aa"));
        childNodes.add(new NodeModel<>("aa"));
        childNodes.add(new NodeModel<>("aa"));
        return childNodes;
    }

    private LinkedList<NodeModel<String>> getChildeNodes2() {

        LinkedList<NodeModel<String>> childNodes = new LinkedList<NodeModel<String>>();
        NodeModel<String> node = new NodeModel<>("bb");
        childNodes.add(node);
        childNodes.add(new NodeModel<>("bb"));
        childNodes.add(new NodeModel<>("bb"));
        childNodes.add(new NodeModel<>("bb"));
        return childNodes;
    }


}
